Skip to content

fix(server): close stdio transport on stdin close#2473

Open
harshmathurx wants to merge 1 commit into
modelcontextprotocol:mainfrom
harshmathurx:fix/stdio-server-stdin-close
Open

fix(server): close stdio transport on stdin close#2473
harshmathurx wants to merge 1 commit into
modelcontextprotocol:mainfrom
harshmathurx:fix/stdio-server-stdin-close

Conversation

@harshmathurx

Copy link
Copy Markdown

Summary

  • close StdioServerTransport when stdin emits close or end
  • remove stdin lifecycle listeners during transport close
  • add regression coverage for both stdin close paths

Fixes #2002.

Test Plan

  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server test -- packages/server/test/server/stdio.test.ts
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server lint

@harshmathurx harshmathurx requested a review from a team as a code owner July 9, 2026 15:55
@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5f03e88

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2473

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2473

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2473

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2473

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2473

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2473

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2473

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2473

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2473

commit: 5f03e88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: StdioServerTransport doesn't handle stdin close/end — causes zombie process accumulation

1 participant